/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.restaurant.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;

/**
 *
 * @author Dexter
 */
@Entity
@Table(name = "PersonStatuses")
@NamedQueries({
    @NamedQuery(name = "PersonStatuses.findAll", query = "SELECT p FROM PersonStatuses p"),
    @NamedQuery(name = "PersonStatuses.findByPersonStatusId", query = "SELECT p FROM PersonStatuses p WHERE p.personStatusId = :personStatusId"),
    @NamedQuery(name = "PersonStatuses.findByName", query = "SELECT p FROM PersonStatuses p WHERE p.name = :name")})
public class PersonStatuses implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "PersonStatusId")
    private Long personStatusId;
    @Size(max = 40)
    @Column(name = "Name")
    private String name;
    @OneToMany(mappedBy = "personStatusId", fetch = FetchType.LAZY)
    private List<Persons> personsList;

    public PersonStatuses() {
    }

    public PersonStatuses(Long personStatusId) {
        this.personStatusId = personStatusId;
    }

    public Long getPersonStatusId() {
        return personStatusId;
    }

    public void setPersonStatusId(Long personStatusId) {
        this.personStatusId = personStatusId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Persons> getPersonsList() {
        return personsList;
    }

    public void setPersonsList(List<Persons> personsList) {
        this.personsList = personsList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (personStatusId != null ? personStatusId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PersonStatuses)) {
            return false;
        }
        PersonStatuses other = (PersonStatuses) object;
        if ((this.personStatusId == null && other.personStatusId != null) || (this.personStatusId != null && !this.personStatusId.equals(other.personStatusId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return Character.toString(name.charAt(0)).toUpperCase()+name.substring(1);
    }
    
}
